package com.mmall.concurrency.example.threadPool;

import lombok.extern.slf4j.Slf4j;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

@Slf4j
public class ThreadPoolExample4 {

    public static void main(String[] args) {

        // ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
        //
        // // executorService.schedule(new Runnable() {
        // //     @Override
        // //     public void run() {
        // //         log.warn("schedule run");
        // //     }
        // // }, 3, TimeUnit.SECONDS);
        // // executorService.shutdown();
        //
        // executorService.scheduleAtFixedRate(new Runnable() {
        //     @Override
        //     public void run() {
        //         log.warn("schedule run");
        //     }
        // }, 1, 3, TimeUnit.SECONDS);

        Timer timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                log.warn("timer run");
            }
        }, new Date(), 5 * 1000);
    }
}
